home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.cyberramp.net!news
- From: sinan@cyberramp.net (John Noland)
- Newsgroups: comp.lang.c
- Subject: Re: Int to Double, Pl Advise!
- Date: 29 Mar 1996 23:32:07 GMT
- Organization: Prose Software
- Message-ID: <4jhrtn$3nr@newshost.cyberramp.net>
- References: <isa5224.544.315B647A@age2.age.uiuc.edu>
- NNTP-Posting-Host: ramp3-11.cyberramp.net
- X-Newsreader: WinVN 0.99.5
-
- In article <isa5224.544.315B647A@age2.age.uiuc.edu>, isa5224@age2.age.uiuc.edu says...
-
- >I am having problems with the following type conversion. From int to double.
- >If someone can comment:
- >
- >#define Ng 4
- >#define Nr 4
- >
- >#include <stdio.h>
- >#include <math.h>
- >#include <malloc.h>
- >
- >int p0[Ng][Nr];
- >
- >int main(){
- >int i,j,k;
- >float x =0;
- >float y =0;
- >:
- >:
- >:
- >for (i=1; i<Ng; i++) {
- > for (j=1; j<Nr; j++) {
- >
- > x = x + ((double) p0[i,j]) / (double)(j*j); }
- ^^^^^
- This isn't the correct notation for accessing an element of a two dimensional
- array. Instead of [i ,j], try [i][j].
-
- >}
- >
- >I get the following compilation error(s) on MS C++ compiler:
- >error C2440: 'cast' : cannot convert from 'int [4]' to 'double '
-
-
-